using UnityEngine;
using Unity.VisualScripting;
using GameFramework.Sound;
using UnityGameFramework.Runtime;

namespace LS.UGFUnits
{
    [UnitShortTitle("Pause Sound")]
    public class PauseSound: SoundUnit
    {
        [DoNotSerialize]
        [PortLabelHidden]
        public ValueInput SerialId { get; set; }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueInput FadeOutSeconds { get; set; }
        
        protected override void Definition()
        {
            base.Definition();
            SerialId = ValueInput<int>(nameof(SerialId));
            FadeOutSeconds = ValueInput<float>(nameof(FadeOutSeconds), 0);
        }

        protected override ControlOutput In(Flow flow)
        {
            int serialId = flow.GetValue<int>(SerialId);
            float fadeOutSeconds = flow.GetValue<float>(FadeOutSeconds);
            Target?.PauseSound(serialId, fadeOutSeconds);
            return base.In(flow);
        }
    }
}